package com.itheima.health.service.impl;

import com.itheima.health.dao.PhoneLoginDao;
import com.itheima.health.dto.SmsLoginParam;
import com.itheima.health.service.PhoneLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PhoneLoginServiceImpl implements PhoneLoginService {
    @Autowired
    private PhoneLoginDao phoneLoginDao;

    /**
     * 获取验证码
     * @param telephone
     * @param code
     */
    @Override
    public void createPhoneUser(String telephone, String code) {
        phoneLoginDao.createPhoneUser(telephone,code);

    }

    /**
     * 验证码登录
     * @param telephone
     */
    @Override
    public SmsLoginParam findByTelephone(String telephone) {
        SmsLoginParam user = phoneLoginDao.findByTelephone(telephone);
        if (user != null) {
            return user;
        }
        //用户不存在
        return null;
    }

}
